function deletesub(no,sid){
	var flag = window.confirm("您确定要删除订单："+no+" 吗?");
	if(flag==true){
		$.ajax({
			type:"post",
			url:"/deleteSubByNo",
			async:true,
			dataType:"json",
			data:{no:no,sid:sid},
			success:function(data){
				if(data==1){
					$("#right_content").load("/gosubschome");
				}else if(data==3){
					window.alert("在订单下存在房间,如果您需要删除该订单，请前往删除订单下的房间");
				}
			},
			error:function(){
				window.alert("程序异常，请稍后重试！");
			}
		});
	}else{
	}
}

function gocontact1(no){
	$("#right_content").load("gocontact");
	$.ajax({
		type:"post",
		url:"getsubsc",
		async:true,
		data:{no:no},
		dataType:"json",
		success:function(data){
			document.getElementById("linkman").value = data.linkman;
			document.getElementById("email").value = data.email;
			document.getElementById("phone").value = data.phone;
			document.getElementById("save_div").innerHTML = '<a class="btn btn-warning btn-sm" href="javascript:void(0)" onclick="goroombook()">取消</a>&nbsp;&nbsp;<a class="btn btn-primary btn-sm" href="javascript:void(0)" onclick="updatesubsc(\''+no+'\')">保存</a>';
		},
		error:function(){
			window.alert("内部故障，请稍后重试！");
		}
	});
}

function updatesubsc(no){
	var email = $("#email").val();
	var phone  = $("#phone").val();
	var linkman = $("#linkman").val();
	var patter = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
	if(email==""||phone==""||linkman==""){
		window.alert("输入的信息不正确！");
	}else{
		if(!patter.test(email)){
			window.alert("输入信息有误。");
		}else{
			$.ajax({
				type:"post",
				url:"updatesub",
				async:true,
				data:{no:no,email:email,phone:phone,linkman:linkman},
				dataType:"json",
				success:function(data){
					if(data==1){
						$("#right_content").load("/gosubschome");
					}
				},
				error:function(){
					window.alert("内部故障，请稍后重试！");
				}
			});
		}
	}
}
function gocontact2(){
	$("#right_content").load("gocontact2");
}
function gocrs(sid){
	$("#right_content").load("queryAllSubCateR?sid="+sid);
}
function cresub(){
	var email = $("#email").val();
	var phone  = $("#phone").val();
	var linkman = $("#linkman").val();
	var patter = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
	if(email==""||phone==""||linkman==""){
		window.alert("输入的信息不正确！");
	}else{
		if(!patter.test(email)){
			window.alert("输入信息有误。");
		}else{
			$.ajax({
				type:"post",
				url:"createsub",
				async:true,
				data:{email:email,phone:phone,linkman:linkman},
				dataType:"json",
				success:function(data){
					if(data==1){
						$("#right_content").load("/gosubschome");
					}
				},
				error:function(){
					window.alert("内部故障，请稍后重试！");
				}
			});
		}
	}
}